classes = [
    {"name": "n_1", "age": 24, "grade": "A"},
    {"name": "n_2", "age": 23, "grade": "B"},
    {"name": "n_3", "age": 28, "grade": "A"},
    {"name": "n_4", "age": 24, "grade": "A"},
    {"name": "n_5", "age": 25, "grade": "C"},
    {"name": "n_6", "age": 21, "grade": "D"},
    {"name": "n_7", "age": 27, "grade": "A"},
]
from pprint import pprint

l = classes
# 根据grade来排序
l.sort(key=lambda x: x["grade"])
pprint(list(l))
print("…………………………………………………………………………………………………………")
# 通过filter语句来筛选出Grade为A的同学
f = filter(lambda x: x["grade"] == "A", l)
pprint(list(f))
print("…………………………………………………………………………………………………………")


# 通过map函数将上述同学的age + 1
def age_1(a):
    a["age"] += 1
    return a


m = map(age_1, l)
pprint(list(m))
print("…………………………………………………………………………………………………………")


# 使用递归函数重构100以内的斐波那契函数
def Fibonacci(n):
    if (n < 2):
        return n
    else:
        return Fibonacci(n - 1) + Fibonacci(n - 2)


for i in range(20):
    if Fibonacci(i) < 100:
        print(Fibonacci(i))
    else:
        break
